package com.jh.paymentchannel.service;

import cn.jh.common.utils.ResultWrap;
import com.jh.paymentchannel.business.PaymentOrderStatisticBusiness;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


/**
 * @author Fuchun
 * @since 1.0
 */
@RestController
@RequestMapping("/v1.0/paymentchannel")
public class PaymentOrderService {

    private final PaymentOrderStatisticBusiness paymentOrderStatisticBusiness;

    @Autowired
    public PaymentOrderService(PaymentOrderStatisticBusiness paymentOrderStatisticBusiness) {
        this.paymentOrderStatisticBusiness = paymentOrderStatisticBusiness;
    }

    @PostMapping(value = "/order_stats/verify", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Map<String, Object> verifyPosSync(@RequestBody List<Long> posIds) {
        Map<Long, Boolean> posIdToVerified = paymentOrderStatisticBusiness.verifySyncPosIds(posIds);
        return ResultWrap.ok("Finished", posIdToVerified);
    }
}
